package ema.tpjee.banking.dao;

import controler.BankControler;
import controler.CustomerControler;
import controler.StartControler;

public class Test {
	StartControler startControler = new StartControler();
	BankControler bankControler = new BankControler();
	CustomerControler customerControler = new CustomerControler();
	BankApplicationDaoImpl bankDao = new BankApplicationDaoImpl();
	CustomerDaoImpl custDao = new CustomerDaoImpl();

	public static void main(String[] a) {
		Test t = new Test();
		t.go();
	}

	private SessionFacade createSession() {
		// ListView bankView = new ListViewImpl();
		// ListView customerView = new ListViewImpl();
		SessionFacade result = new SessionFacade();
		result.setBankDao(bankDao);
		result.setCustomerDao(custDao);
		result.setStartControler(startControler);
		result.setBankControler(bankControler);
		result.setCustomerControler(customerControler);
		// result.setBankView(bankView);
		// result.setCustomerView(customerView);
		return result;
	}

	void check(String s, String expected) {
		if (!s.equals(expected))
			throw new RuntimeException();
	}

	public void go() {
		String nextv = null;
		SessionFacade sf1 = createSession();
		nextv = sf1.getStartControler().listBanks();
		check(nextv, "banks");
		sf1.banksToView();
		System.out.println(sf1.getBankView());
		sf1.setCurrentBank(1);
		nextv = sf1.getBankControler().edit();
		check(nextv, "edit");
		sf1.banksToView();
		System.out.println(sf1.getBankView().getCurrentValue());
		nextv = sf1.getBankControler().list();
		check(nextv, "list");
		sf1.banksToView();
		System.out.println(sf1.getBankView());
		sf1.setCurrentBank(102);
		nextv = sf1.getBankControler().edit();
		check(nextv, "edit");
		sf1.banksToView();
		System.out.println(sf1.getBankView().getCurrentValue());
	}

}
